[PATCH 2/3] term/serial: Reject caller-supplied port addresses under lockdown
The serial command is available in lockdown mode and the port option
accepts a raw port address or a raw mmio base address. This can be
misused to allow an attacker to write to local memory and do things
including disabling / bypassing secure boot as long as the
console is available or an unsigned GRUB configuration is under
the attacker's control.
Update the serial logic to only accept a raw address in lockdown when
a port is already registered at it, which means the platform described
that UART: grub_ns8250_init() for the legacy com<N> ports,
grub_pciserial_init() for an enumerated PCI device, or an ACPI SPCR
UART once "auto" has parsed the table. Names that are not addresses
are untouched, so "auto", efi<N> from grub_efiserial_init() - the
route on arm64, which has neither ns8250 nor SPCR support - and
lookups by registered name all keep working.
Behavior without lockdown (no secure boot) is unchanged.
Assisted-by: Claude:Opus-5
(Tweaked to fit into the 2.14 codebase by Steve McIntyre <93sam@debian.org>
Signed-off-by: Andrew Hamilton <adhamilt@gmail.com> Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Leo Sandoval <lsandova@redhat.com>
Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/266>
Gbp-Pq: Topic upstream
Gbp-Pq: Name 0002-term-serial-Reject-caller-supplied-port-addresses-un.patch